package com.example.service.impl;

import com.example.mapper.DeptMapper;
import com.example.pojo.Dept;
import com.example.service.DeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

/**
 * DeptServiceImpl 类的描述信息
 *
 * @author 12427
 * @since 2025/6/3 10:06
 */
@Service
public class DeptServiceImpl implements DeptService {
    @Autowired
    private DeptMapper deptMapper;

    @Override
    public List<Dept> findAll() {
        return deptMapper.findAll();
    }

    @Override
    public void deletrById(Integer id) {
      deptMapper.deleteById(id);
    }

    @Override
    public void add(Dept dept) {
//    补全时间双属性  create_time update_time
        dept.setCreateTime(LocalDateTime.now());
        dept.setUpdateTime(LocalDateTime.now());
        deptMapper.insert(dept);
    }
    /**
     *  查询回显
     */
    @Override
    public Dept findid(Integer id) {
        return deptMapper.findId(id);
    }

    @Override
    public void update(Dept dept) {
//        补全跟新时间
        dept.setUpdateTime(LocalDateTime.now());
//        调用mapper方法
        deptMapper.update(dept);
    }

}
